//
//  JMEmptyView.m
//  JMBaseProject
//
//  Created by Liuny on 2019/12/7.
//  Copyright © 2019 liuny. All rights reserved.
//

#import "JMEmptyView.h"
#import "JMEmptyStyleView.h"

@interface JMEmptyView ()
@property (nonatomic, strong) JMEmptyStyleView *styleView;
@end

@implementation JMEmptyView

-(instancetype)initWithCoder:(NSCoder *)coder{
    self = [super initWithCoder:coder];
    if(self){
        [self initControl];
    }
    return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self initControl];
    }
    return self;
}
-(void)initControl{
    self.backgroundColor = kColorBackgroundGray;
    self.styleView = [[JMEmptyStyleView alloc] initWithXib];
    [self addSubview:self.styleView];
    [self.styleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    @weakify(self)
    UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
        @strongify(self)
        [self touchAction];
    }];
    [self addGestureRecognizer:ges];
    self.userInteractionEnabled = YES;
}
-(void)touchAction{
    !self.touchActionBlock?:self.touchActionBlock();
}
#pragma mark - Public
-(void)showWithType:(JMEmptyType)type{
    NSString *tipText;
    NSString *tipIcon;
    switch (type) {
        case JMEmptyType_Search:
            tipIcon = @"Empty_Icon";
            tipText = @"没有搜索到相关内容";
            break;
        case JMEmptyType_Fans:
            tipIcon = @"Empty_Fans";
            tipText = @"暂无粉丝";
            break;
        case JMEmptyType_Attention:
            tipIcon = @"Empty_Attention";
            tipText = @"暂未关注，快去关注感兴趣的小伙伴吧！";
            break;
        case JMEmptyType_LivePage:
            tipIcon = @"Empty_Attention";
            tipText = @"暂无直播～";
            break;
        case JMEmptyType_Video:
        case JMEmptyType_Article:
        case JMEmptyType_Picture:
            tipIcon = @"Empty_Video";
            tipText = @"暂无作品";
            break;
        case JMEmptyType_Cart:
            tipIcon = @"Empty_Good";
            tipText = @"购物车里没有东西~";
            break;
        case JMEmptyType_Comment:
            tipIcon = @"Empty_Message";
            tipText = @"暂无评论~";
            break;
        case JMEmptyType_Message:
            tipIcon = @"Empty_Message";
            tipText = @"暂无消息";
            break;
        case JMEmptyType_Pai:
            tipIcon = @"Empty_Video";
            tipText = @"暂无上传拍卖专题";
            break;
        case JMEmptyType_Good:
            tipIcon = @"Empty_Good";
            tipText = @"暂无商品";
            break;
        case JMEmptyType_ZhongGe:
            tipIcon = @"Empty_Video";
            tipText = @"暂无种鸽";
            break;
        case JMEmptyType_Custon:
            tipIcon = @"Empty_Video";
            tipText = @"暂无数据";
            break;
        case JMEmptyType_Note:
            tipIcon = @"Empty_Video";
            tipText = @"暂无简介";
            break;
        case JMEmptyType_NoLogin:
            tipIcon = @"Empty_Video";
            tipText = @"登陆账号，查看更多精彩内容";
            break;
        case JMEmptyType_NoOrder:
            tipIcon = @"Empty_Video";
            tipText = @"暂无更多订单";
            break;
        case JMEmptyType_NoDetail:
            tipIcon = @"Empty_Good";
            tipText = @"暂无账单明细";
            break;
        default:
            break;
    }
//    self.styleView.iconImageView.image = [UIImage imageNamed:tipIcon];
//    self.styleView.tipLabel.text = tipText;
    self.styleView.iconStr = tipIcon;
    self.styleView.tipStr = tipText;
    self.hidden = NO;
}

-(void)hide{
    self.hidden = YES;
}

@end
